package org.goj.user.controller;


import cn.hutool.core.lang.Assert;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.goj.common.entity.user.TeamUser;
import org.goj.common.model.Result;
import org.goj.user.service.TeamUserService;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 团队用户关联 前端控制器
 * </p>
 *
 * @author CK
 * @since 2021-05-05
 */
@RestController
@RequestMapping("/team-user")
public class TeamUserController {

    @Resource
    private TeamUserService teamUserService;

    /**
     * 验证用户能否访问
     *
     * @param teamId 团队ID
     * @param email  用户邮箱
     * @return Result<Boolean>
     * @author CK
     * @date 2021/5/8 17:36
     */
    @PostMapping("/validateTeamUser")
    public Result<Boolean> validateTeamUser(@RequestParam(value = "teamId") Integer teamId,
                                            @RequestParam(value = "email") String email) {
        boolean flag = teamUserService.listValidate(teamId, email);
        if (flag) {
            return Result.succeed("验证通过", true);
        } else {
            return Result.succeed("你无权访问此记录，请联系管理员加入团队", false);
        }
    }

}

